<!DOCTYPE html>
<html>
<!--
Copyright 2008 The Closure Library Authors. All Rights Reserved.

Use of this source code is governed by an Apache 2.0 License.
See the COPYING file for details.
-->
<!--

  @author andybons@google.com (Andrew Bonventre)
-->
<head>
<title>Closure Unit Tests - goog.testing.MockUserAgent</title>
<script src="../base.js"></script>
<script>
  goog.require('goog.testing.MockUserAgent');
  goog.require('goog.testing.jsunit');
  goog.require('goog.userAgent');
</script>
</head>
<body>
<script>

  function testMockUserAgentInstall() {
    var userAgent = new goog.testing.MockUserAgent();

    var originalUserAgentFunction = goog.userAgent.getUserAgentString;

    assertFalse(!!userAgent.installed_);

    userAgent.install();
    assertTrue(userAgent.installed_);
    assertNotEquals(goog.userAgent.getUserAgentString,
        originalUserAgentFunction);

    userAgent.uninstall();
    assertFalse(userAgent.installed_);
    assertEquals(originalUserAgentFunction, goog.userAgent.getUserAgentString);
  }

  function testMockUserAgentGetAgent() {
    var uaString = 'Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US) ' +
        'AppleWebKit/525.13 (KHTML, like Gecko) ' +
        'Chrome/0.2.149.27 Safari/525.13';

    var userAgent = new goog.testing.MockUserAgent();
    userAgent.setUserAgentString(uaString);
    userAgent.install();

    assertTrue(userAgent.installed_);

    assertEquals(uaString, goog.userAgent.getUserAgentString());
  }

</script>
</body>
</html>
